POV-Ray : Newsgroups : povray.text.scene-files : UniversalBeams and a MAcro Question : UniversalBeams and a MAcro Question Server Time
3 Jul 2024 02:30:54 EDT (-0400)
  UniversalBeams and a MAcro Question  
From: Rob Brown-Bayliss
Date: 3 Oct 2001 07:02:05
Message: <3bbaf02d@news.povray.org>
Hi, I have a macro here, that some folks might find handy.  It creates
Universal (or I beams) with the ablitiy to bore holes at regular
intervals.

I also have a question (I'm a regular newbi to POV-ray, and 3d in
general) about default values in macros.

Can I do this:

#macro MyMacro(A, B, C=0, D=1, E=2)

and have C, D and E default to the values if the user leave them out, eg
user calls 

MyMacro(3,6,2)  

And pov trates this as MyMacro(3,6,2,1,2)?


Any way here is the I beam macro...  It would be nice if people caould
point out ways to improve it as well. Thanks




// I Beam macro

#macro IBeam(Length, Hole, Step, W, H, T)
	// IBeam will be centered around <0,0,0>
	// While I call it an IBeam (or Universal Beam)
	// The W is on the x axis, H on the Y axis, Length on Z
	// H is the vertical bar of the I, W the top and bottom caps.
	// T is the thickness of the material.
	// Hole and stpe are used to place holes in the vertial bar.
	// Step is min wanted, might be bigger

	difference
	{
		// First Box is size of beam
		box	
		{
			<-(H/2),-(W/2),-(Length/2)>,
			<(H/2),(W/2),(Length/2)>
		}
		// Second box take hunk out of bottom
		box	
		{
			<-((H/2)-T),-W,-Length>,
			<((H/2)-T),-(T/2),Length>
		}
		// Third box take a bit from the top
		box	
		{
			<-((H/2)-T),(T/2),-Length>,
			<((H/2)-T),W,Length>
		}
		#if (Hole > 0)
			// Always one gap more than num holes 
			#local NumHoles = int(Length/(Step+Hole))
			#local Gap = (Length - (Hole*NumHoles)) / NumHoles
			#local Start = Length/2
			#local Pos = (Gap/2) + (Hole/2)
			#while (Pos < Length)
			object
			{
				sphere {<0,0,Start - Pos>, Hole/2}
			}
			#local Pos=Pos+Hole+Gap
			#end
		#end
	}
#end

-- 

  Rob Brown-Bayliss
 ---======o======---


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.